Looping in Python and keeping current line after sub routine [migrated]

Posted by Brendan on Programmers See other posts from Programmers or by Brendan
Published on 2011-06-29T04:52:00Z Indexed on 2011/06/29 8:30 UTC
Read the original article Hit count: 327

Filed under:

I've been trying to nut out an issue when looping in python 3. When returning from sub routine the "line" variable has not incremented.

How do I get the script to return the latest readline from the subsroutine?

Code below

def getData(line):
      #print(line)
      #while line in sTSDP_data:
      while "/service/content/test" not in line:
            line = sTSDP_data.readline()

import os, sys

sFileTSDP = "d:/ess/redo/Test.log"
sTSDP_data = open(sFileTSDP, "r")

for line in sTSDP_data:
      if "MOBITV" in line:
            getData(line)   #call sub routine
            print(line)

© Programmers or respective owner

Related posts about python